Skip to content

perf(runtime): cache runtime state in memory to reduce notification latency#474

Merged
Orinks merged 1 commit intodevfrom
perf/runtime-state-hotpath-cache
Mar 17, 2026
Merged

perf(runtime): cache runtime state in memory to reduce notification latency#474
Orinks merged 1 commit intodevfrom
perf/runtime-state-hotpath-cache

Conversation

@Orinks
Copy link
Owner

@Orinks Orinks commented Mar 17, 2026

Summary

  • add in-memory cache to RuntimeStateManager so the notification hot path avoids redundant disk reads
  • load_state and load_section serve from cache after the first disk read
  • save_state writes through to disk and updates the cache atomically
  • skip os.fsync on Windows where os.replace is atomic enough
  • fix legacy-section detection to check whether the unified state file actually exists rather than checking for a populated dict (which could be a default)

Effect

  • before: every notification check did a full disk read + possibly a disk write
  • after: only the first read hits disk; subsequent reads and all saves are cache-first

Testing

  • pytest tests/test_runtime_state_manager.py tests/test_alert_manager.py tests/test_notification_event_manager.py tests/test_split_notification_timers.py tests/test_settings_dialog_portable_copy.py

@Orinks Orinks merged commit cb59ee0 into dev Mar 17, 2026
3 checks passed
@Orinks Orinks deleted the perf/runtime-state-hotpath-cache branch March 17, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant